﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wicresoft.UnifyShow.Business;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Data;

namespace Wicresoft.UnifyShow.BusinessImpl
{

    //如果为Join 拼Sql 比较困难，建议通过数据库视图来做。

    public class Example : Basic, IExample
    {
        private const string selectByName = "select * from Example where name = :name";

        public List<ExampleModel> GetListExampleByName(string name)
        {
            QueryParameter[] attParam = new QueryParameter[] {
                    new QueryParameter(){ OracleDbColumnName="name", OracleDbColumnType=OracleDbType.NVarchar2, OracleDbColumnSize=20,OracleDbColumnValue=name,QueryOperator=QueryOperatorType.like,PredicateType=PredicateType.where},
                    };
            return ModelHelper<ExampleModel>.GetModel_By_QueryParams(attParam, null, null, null, oda);
        }

        public Decimal GetCountByName(string name)
        {

            QueryParameter[] attParam = new QueryParameter[] {
                    new QueryParameter(){ OracleDbColumnName="name", OracleDbColumnType=OracleDbType.NVarchar2, OracleDbColumnSize=20,OracleDbColumnValue=name,QueryOperator=QueryOperatorType.like,PredicateType=PredicateType.where},
                    };
            return ModelHelper<ExampleModel>.GetModelCount_By_QueryParams(attParam, oda);
        }


        public List<ExampleModel> GetListExampleByName(string name, int everyPageSize, int index/*start at 0*/)
        {
            QueryParameter[] attParam = new QueryParameter[] {
                    new QueryParameter(){ OracleDbColumnName="name", OracleDbColumnType=OracleDbType.NVarchar2, OracleDbColumnSize=20,OracleDbColumnValue=name,QueryOperator=QueryOperatorType.like,PredicateType=PredicateType.where},
                    };
            return ModelHelper<ExampleModel>.GetModel_By_QueryParams(attParam, null, 9, 1, oda);
        }

        public List<ExampleModel> GetListExampleByNameDirectSql(string name)
        {
            return ModelHelper<ExampleModel>.GetModel_By_DirectSql(selectByName, new List<OracleParameter>()
                 {
                     new OracleParameter(){ ParameterName="name",OracleDbType=OracleDbType.NVarchar2,/*字符串类型必须有Size*/Size=20,Value=name}
                 },
                 oda);
        }
    }
}
